<?php

namespace Home\Controller;

use Think\Controller;
use Think\Log;

import ( "Home.Library.QueryList.QueryList" );
class Meituanwm {
	private $dbdingdan = array ();
	private $dbsubdingdan = array ();
	private $filename = "/Users/jdong/project/tpxbb/public/pc/mt.demo";
	private $fileDir = "/Users/jdong/project/xbbcrm/tpxbb/public/pc/";
	private $dmid = "mtxjk"; // "xbbxjkd";
	private $cookie="pushToken=5d3b526a-1a36-431c-894b-c5914f853f91; __mta=153924103.1451805334943.1451818432983.1451818438180.67; _gat=1; acctId=3426345; token=0PdtR50otVdxQvPXmrC1rEpigky24A7pAVmGFfno10UY*; brandId=-1; wmPoiId=495480; autoAcceptWmPoiList=; isOfflineSelfOpen=0; city_id=110100; shopCategory=food; isChain=0; existBrandPoi=true; userName=xbab25; JSESSIONID=bjp2obtalsue1ixc8tzi7j8av; _ga=GA1.2.1717629163.1451805335; orderReminderCount=0; orderRefundCount=0; wpush_server_url=wss://wpush.meituan.com";


	public function index() {
		// $this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>！</p><br/>版本 V{$Think.version}</div><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_55e75dfae343f5a1"></thinkad><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');
		
		// 每隔7天递增
		$ordertime = "2016-02-01";
		$da = date ( "Y-m-d", strtotime ( $ordertime ) );
		
		echo "今天:", date ( 'Y-m-d H:i:s' ), "<br>";
		echo "明天:", date ( 'Y-m-d H:i:s', strtotime ( '+1 day' ) );
	}
	public function login() {
		require_once C ( 'CUSTOM_LIBRARY' ) . '/httpful-2.phar';
		
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
		// echo "百度外卖";
		
//		$cookiearray = array (
//				"mt" => "pushToken=5d3b526a-1a36-431c-894b-c5914f853f91; __mta=153924103.1451805334943.1451818432983.1451818438180.67; acctId=3426345; token=dc0d6c10-adc2-4cbe-b96d-cda909a9ffa7; brandId=-1; wmPoiId=495480; autoAcceptWmPoiList=; isOfflineSelfOpen=0; city_id=110100; shopCategory=food; isChain=0; existBrandPoi=true; userName=xbab25; orderReminderCount=0; JSESSIONID=14ylj5btcgx9d16mf4ip3x0mpg; _ga=GA1.2.1717629163.1451805335; wpush_server_url=wss://wpush.meituan.com; orderRefundCount=0"
//		);
		
		$cookie =$this->cookie;// $cookiearray ["mt"];
		
		// 载入cookie数据
		
		$cookie = preg_replace ( '/[\r\n]+/', '', $cookie );
		$headers = array (
				'Cookie' => $cookie,
				'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36' 
		);
		
		// $url = "http://wmcrm.baidu.com/crm?qt=orderlist&order_status=0&start_time=2016-01-05&end_time=2016-01-06&pay_type=2&is_asap=0";
		
		$para = array ();
		$start = "2015-10-20";
		for($i = 0; $i < 32; $i ++) {
			$end = date ( 'Y-m-d', strtotime ( '+6 day', strtotime ( $start ) ) );
			
			$para [$start] = $end;
			$start = $end;
		}
		
		// var_dump($para);
		
		// $url = "http://e.waimai.meituan.com/v2/order/history/r/query?wmOrderPayType=-2&wmOrderStatus=-2&sortField=1&startDate=2015-12-01&endDate=2015-12-07&pageNum=1";
		
		$week = 1;
		$urlpre = "http://e.waimai.meituan.com/v2/order/history/r/query?wmOrderPayType=-2&wmOrderStatus=-2&sortField=1&startDate=";
		foreach ( $para as $start => $end ) {

			if($week<24)
			{


			}else
			{

				$url = $urlpre . $start . "&endDate=" . $end . "&pageNum=1";
				$filename = $this->fileDir . $this->dmid . "-" . $week . "-1";



				$request = \Httpful\Request::get ( $url )->addHeaders ( $headers );
				$resp = $request->withoutAutoParsing ()->send ();

				$content = $resp->body;

				file_put_contents ( $filename, $content );
				echo $filename . "</br>";
				$dd = json_decode ( $content, true );
				$pagecount = $dd ["pageCount"];

				echo $url . "</br>";
				echo "pageCount=" . $pagecount . "</br>";

				for($i = 2; $i <= $pagecount; $i ++) {

					$url = $urlpre . $start . "&endDate=" . $end . "&pageNum=" . $i;
					$filename = $this->fileDir . $this->dmid . "-" . $week . "-" . $i;

					if (file_exists ( $filename )) {
					} else {
						$request = \Httpful\Request::get ( $url )->addHeaders ( $headers );
						$resp = $request->withoutAutoParsing ()->send ();

						$content = $resp->body;

						file_put_contents ( $filename, $content );

						echo $filename . "</br>";
					}
				}


			}


			
			$week = $week + 1;
			$start = $end;
		}
		
		// $request = \Httpful\Request::get ( $url )->addHeaders ( $headers );
		// $resp = $request->withoutAutoParsing ()->send ();
		
		// $content = $resp->body;
		
		// $dd = json_decode ( $content,true );
		// $pagecount=$dd["pageCount"];
		
		// var_dump ( $content );
		
		// pageCount
		
		// $res = file_put_contents ( $this->filename, $content );
		
		// $dd = json_decode ( $content,true );
		
		// var_dump($dd);
		
		// foreach ($dd as $key => $value) {
		
		// echo "key=".$key." value=".$value;
		
		// }
	}
	function geturlcontent($header, $url) {
	}
	function loginzp() {
		require_once C ( 'CUSTOM_LIBRARY' ) . '/httpful-2.phar';
		
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
		// echo "百度外卖";
		
		$cookiearray = array (
				// "mt" => "JSESSIONID=9DA4213F9C97631E2AD0AA591B9BF039"
				// "mt" => "JSESSIONID=B696D184DE83557B3A0B01F1470418B8"
				"mt" => "JSESSIONID=99DE4FFF02E32907DAC99205D9384FA0" 
		);
		
		$cookie = $cookiearray ["mt"];
		
		// 载入cookie数据
		
		// Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
		// Accept-Encoding:gzip, deflate, sdch
		// Accept-Language:zh-CN,zh;q=0.8
		// Connection:keep-alive
		// Cookie:JSESSIONID=9DA4213F9C97631E2AD0AA591B9BF039
		// Host:www.zhongwangyinke.cn
		// Referer:http://www.zhongwangyinke.cn/interactive_new/resume/resumesearch.jsp?keyword=%E4%BA%A7%E5%93%81&city=&optype=&type=&dis=&curPageNO=5&pageSize=3000
		// Upgrade-Insecure-Requests:1
		// User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
		
		$cookie = preg_replace ( '/[\r\n]+/', '', $cookie );
		$headers = array (
				'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
				'Accept-Encoding' => 'gzip, deflate, sdch',
				'Accept-Language' => 'zh-CN,zh;q=0.8',
				'Connection' => 'keep-alive',
				'Cookie' => $cookie,
				'Upgrade-Insecure-Requests' => '1',
				'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36' 
		);
		
		// $keyword = "%E4%BA%A7%E5%93%81"; // 产品
		$pageSize = 3000;
		// $keyword="%E8%B4%A2%E5%8A%A1"; //财务
		// $keyword="%E4%BA%BA%E5%8A%9B"; //人力
		// $keyword="%E8%BF%90%E8%90%A5"; //运营
		// $keyword="%E5%89%8D%E7%AB%AF"; //前端
		// $keyword="%E6%95%B0%E6%8D%AE%E5%BA%93"; //数据库
		// $keyword="%E6%B5%8B%E8%AF%95"; //测试
		
		// $keyword="%E9%A3%8E%E6%8E%A7"; //风控
		
		// $keyword="%E6%9E%B6%E6%9E%84%E5%B8%88"; //架构师
		// $keyword="%E9%94%80%E5%94%AE"; //销售
		// $keyword="bd"; //bd
		$keyword = "%E7%BB%8F%E7%90%86"; // 经理
		
		$urlpre = "http://www.zhongwangyinke.cn/interactive_new/resume/resumesearch.jsp?keyword=" . $keyword . "&city=&optype=&type=&dis=&pageSize=" . $pageSize . "&curPageNO=";
		// $urlpre = "http://www.zhongwangyinke.cn/interactive_new/resume/resumesearch.jsp?keyword=%E4%BA%A7%E5%93%81&city=&optype=&type=&dis=&pageSize=" . $pageSize . "&curPageNO=";
		
		for($i = 2; $i <= 1; $i ++) {
			
			$url = $urlpre . $i;
			
			$filename = $this->fileDir . "rs-jingli-" . $i . ".htm";
			echo $url, "</br>";
			echo $filename, "</br>";
			
			// $request = \Httpful\Request::get ( $url )->addHeaders ( $headers );
			// $resp = $request->withoutAutoParsing ()->send ();
			
			// $content = $resp->body;
			
			// file_put_contents ( $filename, $content );
		}
	}
	public function deal() {
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
		
		// $filename = "/Users/jdong/project/tpxbb/public/pc/mt.demo";
		$res = file_get_contents ( $this->filename );
		
		// $res="{\"pageCount\":5,\"code\":0,\"totalCount\":41}";
		// echo "res=".$res;
		
		$dd = json_decode ( $res, true );
		
		// var_dump($dd);
		
		foreach ( $dd as $key => $value ) {
			
			echo "key=" . $key . "    value=" . $value . "   c= " . count ( $value ) . "</br>";
			
			$ccc = 0;
			foreach ( $value as $vkey => $vvalue ) {
				$ccc = $ccc + 1;
				echo "      vkey=" . $vkey . "    vvalue=" . $vvalue . "   c= " . count ( $vvalue ) . "</br>";
				echo "<table  border='1'>";
				foreach ( $vvalue as $skey => $svalue ) {
					
					echo " <tr><td> " . $skey . "</td><td>" . $svalue . "</td><td> " . count ( $svalue ) . "</td></tr>";
					if (gettype ( $svalue ) == "array") {
						echo "key=" . $skey . "</br></br>";
						var_dump ( $svalue );
						echo "</br></br>";
						$discount = "";
						foreach ( $svalue as $dkey => $dvalue ) {
							$discount = $discount . "  key=" . $key . " value=" . $dvalue;
							
							if (gettype ( $dvalue ) == "array") {
								echo "dkey=" . $dkey . "</br></br>";
								var_dump ( $dvalue );
								echo "</br></br>";
							}
						}
						echo " <tr><td> " . $skey . "</td><td>" . $discount . "</td><td> " . count ( $svalue ) . "</td></tr>";
					}
				}
				echo "</table>";
				break;
			}
			
			echo "ccc=" . $ccc, "</br>";
		}
	}
	
	// 遍历所有的mtxjk文件
	public function dealdata() {
		$dingdanDb = D ( "dingdan" );
		$subDingdanDb = D ( "subdingdan" );
		
		$mydir = dir ( $this->fileDir );
		
		while ( $file = $mydir->read () ) {
			
			$filename = $this->fileDir . $file;


			
			if (! is_dir ( "$filename" )) {
				
				$posbdfile = stripos ( $filename, "txjk-2" );
				
				if (intval ( $posbdfile ) > 0) {
					Log::record ( $filename, "DEBUG" );
					
					$this->dealmtDb ( $filename, $dingdanDb, $subDingdanDb );
					

				}
			}
		}
		
		$mydir->close ();
	}
	function dealmtDb($filename, $dingdanDb, $subDingdanDb) {
// 		 $filename = $this->filename;
		$submenuItems = array ();
		$dataArray = array ();
		
		$this->dealmtdata ( $filename, $dataArray, $submenuItems );
		
		$dingCount = count ( $dataArray );
		
		for($i = 0; $i < $dingCount; $i ++) {
			
			try {
				$dingdanDb->add ( $dataArray [$i] );
			} catch ( \Think\Exception $e ) {
				
				Log::record ( "mtdingdang添加订单失败 " . $e->getMessage (), "ERR" );
			}
		}
		
		// var_dump ( $dataArray );
		
		// echo "</br></br>";
		
		$subdingCount = count ( $submenuItems );
		
		for($i = 0; $i < $subdingCount; $i ++) {
			
			try {
				$subDingdanDb->add ( $submenuItems [$i] );
			} catch ( \Think\Exception $e ) {
				
				Log::record ( "subdingdan添加订单失败 " . $e->getMessage (), "ERR" );
			}
		}
		
		// var_dump($submenuItems);
	}
	
	/**
	 * [ 2016-02-22T01:20:46+08:00 ] ::1 /tpxbb/wm/mtdealdata
	 * DEBUG: /Users/jdong/project/tpxbb/public/pc/mt.demo
	 * DEBUG: selectedDeliveryTeamCode 0
	 * DEBUG: recipient_phone 18511214000 1
	 * DEBUG: remark 1
	 * DEBUG: actual_pay_type 2 1
	 *
	 * DEBUG: tipsVos Array 2
	 * DEBUG: dkey=0
	 * DEBUG: dkey=1
	 * DEBUG: tipsVos key=wmOrderList value=Array key=wmOrderList value=Array 2
	 * DEBUG: overtime_paid_info 1
	 * DEBUG: autoDispatch 1
	 * DEBUG: pages 1 1
	 * DEBUG: total_before 411 1
	 * DEBUG: selectedDeliveryTeamId 0 1
	 * DEBUG: poi_city_id 110100 1
	 * DEBUG: present 1
	 * DEBUG: interval 0 1
	 * DEBUG: wm_order_pay_type 2 1
	 * DEBUG: total_items 5 1
	 * DEBUG: has_been_invoiced 0 1
	 * DEBUG: delivery_btime_fmt 2015-12-08 00:50 1
	 *
	 * DEBUG: canBeCancelled 0 1
	 * DEBUG: wm_order_id_view 4954800899467936 1
	 * DEBUG: org_emergency_phone 0
	 * DEBUG: canBeHandled 1 1
	 * DEBUG: deliveryType -1 1
	 * DEBUG: apply_refund_type 1 1
	 * DEBUG: reject_reason 1
	 * DEBUG: riderPayment 0
	 * DEBUG: tip_amount 0 1
	 * DEBUG: pay_utime 1449502282 1
	 * DEBUG: shipping_fee 20 1
	 * DEBUG: type 0 1
	 * DEBUG: people_count 0 1
	 * DEBUG: is_cross_day_pre_order 1 1
	 * DEBUG: is_poi_first_order 1
	 * DEBUG: city_id 110100 1
	 * DEBUG: delivery_btime 1449507000 1
	 * DEBUG: tips Array 2
	 * DEBUG: tips key=wmOrderList value=大额订单：该订单金额较大 key=wmOrderList value=在线支付：用户已经在线支付过该订单费用，配送时无需再收取用户费用 2
	 * DEBUG: orderCopyContent 12月7日 #2号单# 虾baby 陈楠(女士) 18511214000 旺座中心公寓 (西塔2207) 经典簋街麻小（1斤） 2份 蒜泥狠（蒜香小龙虾1斤） 1份 不拘一蛤（辣炒花蛤） 1份 大蛏归来（辣炒蛏子） 1份 合计：291.0元 (已付款) 预订单：期望送达时间【2015-12-08 00:50】 在线支付订单 1
	 * DEBUG: selectedDeliveryTeamName 1
	 * DEBUG: dispatchCancelAllow 1 1
	 * DEBUG: is_3rd_part_shipping 0 1
	 * DEBUG: order_source 2 1
	 * DEBUG: caution 1
	 * DEBUG: repeat_order_tip 1
	 * DEBUG: deliveryStatusDesc 1
	 * DEBUG: discount 0 1
	 * DEBUG: cartCount 1 1
	 * DEBUG: fst5coupon_coupon 0 1
	 * DEBUG: invoice_title 1
	 * DEBUG: printCnt 0 1
	 * DEBUG: onlyDispatchTeamName 1
	 * DEBUG: send_fee_free 1
	 * DEBUG: recipient_name 陈楠(女士) 1
	 * DEBUG: shipping_tips 0
	 * DEBUG: onlyDispatchTeamId 0 1
	 * DEBUG: table_num 0
	 *
	 * //116.465026,39.920466
	 * //116.458496,39.915032
	 * //116.458688,39.914508
	 * DEBUG: address_latitude 39915032 1
	 * DEBUG: address_longitude 116458496 1
	 *
	 * DEBUG: longitude 116458688 1
	 * DEBUG: latitude 39914508 1
	 *
	 * DEBUG: poi_latitude 39944453 1
	 * DEBUG: poi_longitude 116372530 1
	 *
	 * DEBUG: wm_poi_id 495480 1
	 *
	 * DEBUG: onlyDispatchTeamCode 0
	 * DEBUG: status_desc 订单完成 1
	 * DEBUG: recipient_address 旺座中心公寓 (西塔2207) 1
	 * DEBUG: dispatch_code 1
	 *
	 * DEBUG: shipping_time 1
	 * DEBUG: num 2 1
	 * DEBUG: order_source_desc 手机APP下单 1
	 * DEBUG: cancel_reason 1
	 * DEBUG: hisUtime 1449577570 1
	 * DEBUG: pre_order_remind 1449505200 1
	 * DEBUG: discounts Array 1
	 * DEBUG: dkey=0
	 * DEBUG: discounts key=wmOrderList value=Array 1
	 * DEBUG: pre_order_tip 预订单：期望送达时间 1
	 * DEBUG: boundDeliveryTeamCount 0 1
	 * DEBUG: dispatcherPhone 1
	 * DEBUG: boxpriceTotal 0 1
	 * DEBUG: shippingFee -1 1
	 * DEBUG: waitingTime 1
	 * DEBUG: latestDeliveryTime 1
	 * DEBUG: other_desc 1
	 * DEBUG: details Array 4
	 * DEBUG: dkey=0
	 * DEBUG: dkey=1
	 * DEBUG: dkey=2
	 * DEBUG: dkey=3
	 * DEBUG: details key=wmOrderList value=Array key=wmOrderList value=Array key=wmOrderList value=Array key=wmOrderList value=Array 4
	 * DEBUG: self_service 1 1
	 * DEBUG: order_time 1449502282 1
	 * DEBUG: dispatcherName 1
	 * DEBUG: fst5coupon_reduce 0 1
	 * DEBUG: id 759057358 1
	 * DEBUG: org_leader_phone 0
	 * DEBUG: apply_reason 1
	 * DEBUG: online_paid_info 在线支付订单 1
	 * DEBUG: is_pre_order 1 1
	 * DEBUG: poi_name 虾baby 1
	 * DEBUG: pay_status_desc 已付款 1
	 * DEBUG: expireTime 1
	 * DEBUG: wm_poi_order_dayseq 2 1
	 * DEBUG: total_after 291 1
	 * DEBUG: order_time_fmt 2015-12-07 23:31:22 1
	 * DEBUG: third_part_shipping_phone 0
	 * DEBUG: deliveryStatus -1 1
	 * DEBUG: city_name 北京 1
	 * DEBUG: third_part_shipping_name 0
	 * DEBUG: pick_up_code 1
	 * DEBUG: pay_status 3 1
	 * DEBUG: wm_order_id_view_str 4954800899467936 1
	 * DEBUG: cartDetailVos Array 1
	 * DEBUG: dkey=0
	 * DEBUG: cartDetailVos key=wmOrderList value=Array 1
	 * DEBUG: pay_utime_fmt 2015-12-07 23:31:22 1
	 *
	 * DEBUG: dispatched 1
	 * DEBUG: status 8 1
	 *
	 *
	 *
	 * 39.914508,116.458688
	 */
	
	// id,ddid,name,sex,mobile,ltrim(rtrim(address)) as address,menu,ordertime,price,userpay,platpay,bosspay,income,status,invoice,shipping,memo
	public function dealmtdata($filename, &$dataArray, &$submenuItems) {
		// $filename = "/Users/jdong/project/tpxbb/public/pc/mt.demo";
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
		
		// Log::record ( $filename, 'DEBUG' );
		$res = file_get_contents ( $filename );
		
		// $res="{\"pageCount\":5,\"code\":0,\"totalCount\":41}";
		// echo "res=".$res;
		
		$dd = json_decode ( $res, true );
		
		// var_dump($dd);
		
		foreach ( $dd as $key => $value ) {
			
			// Log::record("key=" . $key . " value=" . $value . " c= " . count ( $value ) ,'DEBUG');
			
			$ccc = 0;
			foreach ( $value as $vkey => $vvalue ) {
				$ccc = $ccc + 1;
				// Log::record ( " vkey=" . $vkey . " vvalue=" . $vvalue . " c= " . count ( $vvalue ), 'DEBUG' );
				
				$data = array ();
				$posSex = stripos ( $vvalue ["recipient_name"], "(" );
				
				// echo "sex=" . $posSex;
				if ($posSex > 0) {
					$data ["name"] = substr ( $vvalue ["recipient_name"], 0, $posSex );
				} else {
					$data ["name"] = $vvalue ["recipient_name"];
				}
				
				$posSex = stripos ( $vvalue ["recipient_name"], "女士" );
				if ($posSex > 0) {
					$data ["sex"] = 0;
				} else {
					$data ["sex"] = 1;
				}
				
				$data ["sid"] = $this->dmid;
				$data ["mobile"] = $vvalue ["recipient_phone"];
				$data ["invoice"] = $vvalue ["invoice_title"];
				
				$data ["address"] = $vvalue ["recipient_address"];
				$data ["ddid"] = trim ( $vvalue ["wm_order_id_view"] );
				$data ["ordertime"] = $vvalue ["order_time_fmt"];
				$data ["shipping"] = $vvalue ["shipping_fee"];
				$posSex = stripos ( $vvalue ["status_desc"], "单完成" );
				if ($posSex >= 0) {
					$data ["status"] = 1;
				} else {
					$data ["status"] = 0;
				}
				
				$data ["menu"] = $vvalue ["orderCopyContent"];
				$data ["userpay"] = $vvalue ["total_after"]; // 用户实付
				                                             
				// var_dump ( $vvalue ["discounts"] );
				
				$type = $vvalue ["discounts"] [0] ["type"];
// 				 echo $type, "</br>";
				
				if (stripos ( $type, "减20.0" ) > 0) {
					
					$data ["bosspay"] = 20; //
				} else if (stripos ( $type, "减60.0" ) > 0) {
					
					$data ["bosspay"] = 60; //
				} else if (stripos ( $type, "减30.0" ) > 0) {
					
					$data ["bosspay"] = 20; //
					$data ["platpay"] = 10; //
				} else if (stripos ( $type, "减120.0" ) > 0) {
					
					$data ["bosspay"] = 90; //
					$data ["platpay"] = 30; //
				} else if (stripos ( $type, "减150.0" ) > 0) {
					
					$data ["bosspay"] = 120; //
					$data ["platpay"] = 30; //
				}
				
				$data ["income"] = $data ["userpay"] + $data ["platpay"];
				
				if (stripos ( $type, "红包" ) > 0) {
					$data ["income"] = $data ["userpay"] - $vvalue ["discounts"] [0] ["info"]; // 用户实付
					$data ["platpay"] = 0 - $vvalue ["discounts"] [0] ["info"]; // 用户实付
				}
				
				$data ["memo"] = $vvalue ["caution"];
				
				$data ["price"] = $vvalue ["cartDetailVos"] [0] ["cartAmount"]; // 总价
				                                                                
// 				 var_dump ( $data );
				
				$submenu = $vvalue ["cartDetailVos"] [0] ["details"]; // 子订单
				
				$subcount = count ( $submenu );
				if ($subcount > 0) {
					$data ["sub_menu"] = 1;
				}
				
				// echo "subcount=" . $subcount;
				
				// $submenuItems = array ();
				for($i = 0; $i < $subcount; $i ++) {
					
					// var_dump( $submenu[$i] );
					
					// echo "</br></br>";
					
					$submenuItem = array ();
					$submenuItem ["name"] = $submenu [$i] ["food_name"];
					$submenuItem ["current_price"] = $submenu [$i] ["food_price"];
					$submenuItem ["origin_price"] = $submenu [$i] ["food_price"];
					$submenuItem ["number"] = $submenu [$i] ["count"];
					$submenuItem ["total_price"] = $submenuItem ["current_price"] * $submenuItem ["number"];
					$submenuItem ["ddid"] = $data ["ddid"];
					$submenuItem ["subid"] = $submenuItem ["ddid"] . $i;
					
					// var_dump($submenuItem);
					
					array_push ( $submenuItems, $submenuItem );
				}
				
				array_push ( $dataArray, $data );
				
				//
				
				// var_dump($data);
				
				// foreach ( $vvalue as $skey => $svalue ) {
				
				// Log::record ( " sky=" . $skey . " svalue=" . $svalue . " " . count ( $svalue ), 'DEBUG' );
				
				// if (gettype ( $svalue ) == "array") {
				
				// // Log::record( var_dump ( $svalue ) ,'DEBUG');
				
				// $discount = "";
				// foreach ( $svalue as $dkey => $dvalue ) {
				// $discount = $discount . " dkey=" . $key . " dvalue=" . $dvalue;
				
				// if (gettype ( $dvalue ) == "array") {
				
				// foreach ( $dvalue as $ekey => $evalue ) {
				// Log::record ( " ekey=" . $ekey . " evalue=" . $evalue, 'DEBUG' );
				
				// if (gettype ( $evalue ) == "array") {
				
				// foreach ( $evalue as $fkey => $fvalue ) {
				// Log::record ( " fkey=" . $fkey . " fvalue=" . $fvalue, 'DEBUG' );
				
				// if (gettype ( $fvalue ) == "array") {
				
				// echo "</br> fkey=" . $fkey, "</br>";
				// var_dump ( $fvalue );
				// echo "</br></br>";
				// foreach ( $fvalue as $gkey => $gvalue ) {
				// Log::record ( " gkey=" . $gkeykey . " gvalue=" . $gvalue, 'DEBUG' );
				
				// if (gettype ( $gvalue ) == "array") {
				// // Log::record ( " gkey=" . $gkey . " gvalue array=" . $gvalue, 'DEBUG' );
				// }
				// }
				// }
				// }
				// }
				// }
				// }
				// }
				// // Log::record( $skey . " " . $discount . " " . count ( $svalue ) ,'DEBUG');
				// }
				// }
			}
		}
	}
}